/*
 * GNU AGPL-3.0 License
 *
 * Copyright (c) 2021 - present core.ai . All rights reserved.
 * Original work Copyright (c) 2013 - 2021 Adobe Systems Incorporated. All rights reserved.
 *
 * This program is free software: you can redistribute it and/or modify it
 * under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License
 * for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program. If not, see https://opensource.org/licenses/AGPL-3.0.
 *
 */

/* Temporary fix for issue#10150 for weird project tree scrollbar behaviour on mac. Scrollbar not appearing on hover. Forcing the project tree div to render displays the scrollbar. So setting transparent background color of div on hover.
*/

.platform-mac
{
    .open-files-container:hover,
    #project-files-container:hover {
        background-color: rgba(128, 128, 128, 0);
    }
}

/* Temporary implementation of unobtrusive scrollbars.
   FUTURE: These currently rely on nonstandard WebKit styles, and don't have all the right behavior.
   Longer-term, we'll need to implement custom scrollbars. */

.platform-mac .quiet-scrollbars,
.platform-win .quiet-scrollbars,
.platform-linux .quiet-scrollbars,
.dark.platform-mac .quiet-scrollbars,
.dark.platform-win .quiet-scrollbars,
.dark.platform-linux .quiet-scrollbars {

    ::-webkit-scrollbar {
        width: 9px;
        height: 9px;
        background-color: transparent;
    }

    ::-webkit-scrollbar-corner {
        background-color: transparent;
    }

    ::-webkit-scrollbar-thumb {
        box-shadow: none;
        border: none;
    }

    /* This looks like a dupe, but without it the thumb doesn't fade in
     * properly, probably due to flakiness in how these styles are handled
     * in the build of WebKit that's in CEF.
     */
    ::-webkit-scrollbar-corner {
        background-color: transparent;
    }

    .dragging ::-webkit-scrollbar-thumb,
    :hover::-webkit-scrollbar-thumb,
    :focus::-webkit-scrollbar-thumb {
        border-radius: 999px;
        box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.6) inset;
        border: 2px solid transparent;
    }

    .dragging ::-webkit-scrollbar-thumb,
    :hover::-webkit-scrollbar-thumb:vertical,
    :focus::-webkit-scrollbar-thumb:vertical {
        min-height: 20px;
    }

    .dragging :-webkit-scrollbar-thumb,
    :hover::-webkit-scrollbar-thumb:horizontal,
    :focus::-webkit-scrollbar-thumb:horizontal {
        min-width: 20px;
    }
}

.platform-linux, .platform-mac {
    // Note: when changing padding/margins, may need to adjust metrics in ScrollTrackMarkers.js

    ::-webkit-scrollbar {
        width: 12px;
        height: 12px;
    }

    ::-webkit-scrollbar-track:vertical {
        margin: 0 0 8px 0;
    }

    ::-webkit-scrollbar-track:horizontal {
        margin: 0 8px 0 0;
    }

    ::-webkit-scrollbar-thumb {
        border-radius: 999px;
        box-shadow: 0 0 0 5px @linux-scrollbar-thumb inset;
        border: 2px solid transparent;
    }

    ::-webkit-scrollbar-corner {
        background: none;
    }

    ::-webkit-scrollbar-thumb:window-inactive {
        box-shadow: 0 0 0 5px @linux-scrollbar-thumb-inactive inset;
    }
}

.platform-win {
    // Note: when changing padding/margins, may need to adjust metrics in ScrollTrackMarkers.js

    ::-webkit-scrollbar {
        width: 12px;
        height: 12px;
        background-color: transparent;
    }

    ::-webkit-scrollbar:hover {
        background-color:  @win-scrollbar-track;
    }

    ::-webkit-scrollbar-thumb {
        box-shadow: 0 0 0 12px @win-scrollbar-thumb inset;
    }

    .dragging ::-webkit-scrollbar-thumb,
    ::-webkit-scrollbar-thumb:hover,
    ::-webkit-scrollbar-thumb:focus {
        box-shadow: 0 0 0 12px @win-scrollbar-thumb-hover inset;
    }
    ::-webkit-scrollbar-thumb:active {
        box-shadow: 0 0 0 12px @win-scrollbar-thumb-active inset;
    }

    ::-webkit-scrollbar-thumb:vertical {
        min-height: 20px;
    }
    ::-webkit-scrollbar-thumb:horizontal {
        min-width: 20px;
    }

    ::-webkit-scrollbar-corner {
        background: none;
    }
}


// Dark Scrollbars

.dark {
    /* Custom scrollbar colors */
    &.platform-win {
        .CodeMirror-scrollbar-filler {
            background-color:  rgb(30, 30, 30);
        }

        .CodeMirror-gutter-filler {
            background-color: transparent;
        }

        // Note: when changing padding/margins, may need to adjust metrics in ScrollTrackMarkers.js

        ::-webkit-scrollbar {
            background-color: transparent;
        }

        ::-webkit-scrollbar:hover {
            background-color: rgba(15, 15, 15, .5);
        }

        ::-webkit-scrollbar-thumb {
            box-shadow: 0 0 0 12px rgb(49, 49, 49) inset;
        }
        ::-webkit-scrollbar-thumb:hover,
        ::-webkit-scrollbar-thumb:focus {
            box-shadow: 0 0 0 12px rgb(89, 89, 89) inset;
        }
        ::-webkit-scrollbar-thumb:active {
            box-shadow: 0 0 0 12px rgb(169, 169, 169) inset;
        }
    }

    &.platform-linux, &.platform-mac {
        .CodeMirror-scrollbar-filler,
        .CodeMirror-gutter-filler {
            background-color: transparent;
        }

        ::-webkit-scrollbar-thumb {
            box-shadow: 0 0 0 5px rgba(255, 255, 255, 0.24) inset;
        }

        ::-webkit-scrollbar-thumb:window-inactive {
            box-shadow: 0 0 0 5px rgba(255, 255, 255, 0.12) inset;
        }
    }
}
